package com.sc.adminspringboot.service.impl;

import com.sc.adminspringboot.pojo.Posts;
import com.sc.adminspringboot.dao.IPostsDao;
import com.sc.adminspringboot.service.IPostsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户发布帖子主表 服务实现类
 * </p>
 *
 * @author 万超凡
 * @since 2025-09-20 10:36:46
 */
@Service
public class PostsServiceImpl extends ServiceImpl<IPostsDao, Posts> implements IPostsService {

    @Autowired
    private IPostsDao postsDao;
    

    @Override
    public boolean batchApprovePosts(List<Integer> postIds) {
        try {
            // 批量更新审核状态为通过（1）
            int result = postsDao.batchUpdatePostStatus(postIds, (byte) 1);
            return result > 0;
        } catch (Exception e) {
            System.out.println("批量审核通过失败: " + e.getMessage());
            return false;
        }
    }

    @Override
    public List<String> getImageUrlsByPostId(Integer postId) {
        return postsDao.getImageUrlsByPostId(postId);
    }

    @Override
    public boolean batchRejectPosts(List<Integer> postIds) {
        try {
            int result = postsDao.batchUpdatePostStatus(postIds, (byte) 2); // 2-审核不通过
            return result > 0;
        } catch (Exception e) {
            System.out.println("批量拒绝帖子失败: " + e.getMessage());
            return false;
        }
    }
}
